package nc.ui.cmp.report.query;

import nc.ui.querytemplate.ICriteriaChangedListener;
import nc.ui.querytemplate.filter.IFilter;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.pub.query.ConditionVO;
import nc.vo.querytemplate.QueryTemplateConvertor;
import com.ufida.dataset.IContext;

public class CapitalSumQryAction extends AbstractQueryAction {

	@Override
	public void initCriteriaChangedListener(IContext context) {
		// setListeners(new ICriteriaChangedListener[]{  });
		  setListeners(new ICriteriaChangedListener[]{ new
		  OrgCriteriaChangeHandler
		  ((String)context.getAttribute("key_report_funcode"
		  ),"pk_org","pk_org") } );
		 
	}

	@Override
	protected void createParameterByScheme(IQueryScheme queryScheme) {
		String startdate = null;
		String enddate = null;
		String enterprise = null;
		String pk_dept = null;
		Object obj = queryScheme.get("filters");
		IFilter[] iFilters = (IFilter[]) obj;
		if ((obj instanceof IFilter[])) {
			int len = iFilters.length;
			ConditionVO[] conditionVOs = new ConditionVO[len];
			for (int i = 0; i < iFilters.length; i++) {
				conditionVOs[i] = QueryTemplateConvertor
						.convert2ConditionVO(iFilters[i]);
			}

			for (ConditionVO tempVO : conditionVOs) {
				String tempCode = tempVO.getFieldCode();
				if (null != tempCode) {
					if ("startdate".equals(tempCode)) {
						startdate = tempVO.getValue();
					} else if ("enddate".equals(tempCode)) {
						enddate = tempVO.getValue();
					} else if ("enterprise".equals(tempCode)) {
						enterprise = tempVO.getValue();
					} else if ("pk_dept".equals(tempCode)) {
						pk_dept = tempVO.getValue();
					}

				}
			}
		}
		getParameterMap().put("startdate", startdate);
		getParameterMap().put("enddate", enddate);
		getParameterMap().put("enterprise", enterprise);
		getParameterMap().put("pk_dept", pk_dept);

	}

}
